import algorithm.AcoAlg;
import algorithm.data.PositionUtil;

/**
 * @author letere
 * @since  2020-12-24 11:59
 */
public class Sample {
    public static void main(String[] args) {
        sample1();
//        sample2();
    }

    /**
     * 运行样例1
     */
    public static void sample1() {
        /*
        距离矩阵：任意两点的距离，例：a->a距离0，a->b距离1，a->c距离3 ... 以此类推
            a   b   c   d
        a   0   1   3   1
        b   1   0   3   2
        c   3   3   0   2
        d   1   2   2   0
         */
        // 自定义距离矩阵
        int[][] distanceMatrix = new int[][]{
                {0, 1, 3, 1},
                {1, 0, 3, 2},
                {3, 3, 0, 2},
                {1, 2, 2, 0}
        };
        // 运行蚁群优化算法
        AcoAlg acoAlg = new AcoAlg(distanceMatrix, 50, 6);
        acoAlg.execute();
    }

    /**
     * 运行样例2
     */
    public static void sample2() {
        // 蚂蚁数量越多，运行次数越多，数据越准确
        String filePath = "./algorithm/data/position.txt";
        int[][] distanceMatrix = PositionUtil.getDistanceMatrix(filePath);
        AcoAlg acoAlg = new AcoAlg(distanceMatrix, 5000, 50);
        acoAlg.execute();
    }
}
